// File Name SendFileEmail.java
package model.action.suggest_deal_action;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMailConcernDeal {
	public static void main(String[] args) {
		String host = "mail.nhipcaugiaitri247.com";
		String from = "giaitri@nhipcaugiaitri27.com";
		String pass = "Admin-123";
		Properties props = System.getProperties();
		props.put("mail.smtp.host", host);
		props.put("mail.smtp.user", "giaitri");
		props.put("mail.smtp.password", pass);
		props.put("mail.smtp.port", "587");
		props.put("mail.smtp.auth", "true");

		// Recipient's email ID needs to be mentioned.
		String to = "ruaconbmt.91@gmail.com";

		// Get the default Session object.
		Session session = Session.getDefaultInstance(props, null);

		try {
			// Create a default MimeMessage object.
			MimeMessage message = new MimeMessage(session);

			// Set From: header field of the header.
			message.setFrom(new InternetAddress(from));

			// Set To: header field of the header.
			message.addRecipient(Message.RecipientType.TO, new InternetAddress(
					to));


			// Set Subject: header field
			message.setSubject("Cungdeal.com! mail concern deal");

			// Send the actual HTML message, as big as you like
			message.setContent(
					"<p>Chào b?n!! Cungdeal.com xin gi?i thi?u d?n b?n m?t s? s?n ph?m mà b?n quan tâm. Chúc b?n ch?n du?c nh?ng món hàng nhu mong mu?n @.@ Have nice day!!!!</p>" +
					"<a href='http://www.hotdeal.vn/ho-chi-minh/buffet-trua-nha-hang-bbq-house-tu-11h-16h-redeal-22244.html'><img src='http://images.hotdeals.vn/images/detailed/124/new-tn13657493755167ae7f6d88f.jpg'/></a>,"
							+ "<a href='http://www.hotdeal.vn/ho-chi-minh/tour-du-lich-nha-trang-gom-ve-vinpearl-land-3-ngay-3-dem-danh-cho-1-khach-21199.html'><img src='http://images.hotdeals.vn/images/detailed/121/tn1365045681515cf1b1b3b6a.jpg'/>,"
							+ "<a href='http://nhanhmua.vn/deal/ipad-do-choi-thong-minh-cho-be/669'><img src='http://nhanhmua.vn/static/team/2012/0908/13470713648533.jpg'/>,"
							+ "<a href='http://www.hotdeal.vn/ho-chi-minh/quan-short-nu-kaki-hoa-21800.html'><img src='http://images.hotdeals.vn/images/detailed/124/tn13657564735167ca3977a40.jpg'/>",
					"text/html; charset=utf-8");
			
			
			// Send message
			Transport transport = session.getTransport("smtp");
			transport.connect(host, "giaitri", pass);
			transport.sendMessage(message, message.getAllRecipients());
			transport.close();
			System.out.println("Sent message successfully....");

		} catch (MessagingException mex) {
			mex.printStackTrace();
		}
	}
}